package com.weiyan.dao;

import com.weiyan.domian.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author misterWei
 * @create 2020年02月20号:20点20分
 * @mailbox mynameisweiyan@gmail.com
 */
@Repository
public interface ProductDao extends JpaRepository<Product,Integer>,JpaSpecificationExecutor<Product> {

    @Modifying
    @Query(nativeQuery = true,value = "UPDATE shop_product SET stock = stock - 1 where pid = ?1")
    void decrement(Integer pid);


}
